<?php
header("Content-type:text/html;charset=utf-8");
//验证登录
if(isset($_POST)){
	//假如有提交数据，接收数据
	@$username = $_POST['username'];
	@$password = $_POST['password'];
	
	//连接数据库
	$server = 'localhost';
	$user = 'root';
	$psw = 'root';
	$db = 'qq';
	$conn = new PDO("mysql:host=$server;dbname=$db",$user,$psw);
	
	$check = $conn->query("select * from user where username='$username' and password='$password'");
	$res = $check->fetch(PDO::FETCH_ASSOC);
	
	if($res){
		
        //登录成功，开始session
        session_start();
        $_SESSION['username'] = $username;
        $_SESSION['id'] = $res['id'];
        header('Location:onload.php');

	}else{
		
		include 'index.html';
	}
}


// include 'index.html';

